<template>
  <div id="table">
    <el-row>
      <el-input v-model="input1" style="width:200px"placeholder="请输入设备代码" ></el-input>
      <el-button type="primary" @click="searchDevice">搜索设备</el-button>
      <el-button type="primary" @click="show">查看所有</el-button>
      <router-link  class="filter-item" to="/otherdata/productdesign/create">
        <el-button type="primary">添加设备</el-button>
      </router-link>
    </el-row>

      <el-table
        :data="productTable" border style="width: 100%">
        <el-table-column label="设备名称" width="200" prop="deviceName"/>
        <el-table-column label="容器类别" width="200" prop="containerType"/>
        <el-table-column label="设备代码" width="200" prop="deviceCode"/>
        <el-table-column label="使用登记证编号" width="200" prop="registerCode"/>
        <el-table-column label="单位内编号" width="200" prop="unitCode"/>
        <el-table-column label="制造单位" width="200" prop="makeUnit"/>
        <el-table-column label="安装单位" width="200" prop="installUnit"/>
        <el-table-column label="使用单位" width="200" prop="useUnit"/>
        <el-table-column label="使用单位地址" width="200" prop="useUnitAdress"/>
        <el-table-column label="设备使用地点" width="200" prop="usePosition"/>
        <el-table-column label="使用单位组织机构代码" width="200" prop="useUnitCode"/>
        <el-table-column label="安全管理人员" width="200" prop="safeManager"/>
        <el-table-column label="联系电话" width="200" prop="telephone"/>
        <el-table-column label="设计使用年限" width="200" prop="useLife"/>
        <el-table-column label="使用投入日期" width="200" prop="useDate"/>
        <el-table-column label="主体机构形式" width="200" prop="subjectStructureForm"/>
        <el-table-column label="运行状态" width="200" prop="state"/>
        <el-table-column label="容积" width="200" prop="volume"/>
        <el-table-column label="内径" width="200" prop="internalDiameter"/>
        <el-table-column label="设计压力" width="200" prop="designPressure"/>
        <el-table-column label="设计温度" width="200" prop="designTemperature"/>
        <el-table-column label="使用压力" width="200" prop="usePressure"/>
        <el-table-column label="使用温度" width="200" prop="useTemperature"/>

        <el-table-column align="center" label="操作" width="200">
          <template slot-scope="scope">
            <el-button type="primary" size="mini" icon="el-icon-edit" v-show="!scope.row.root" @click="editPeople(scope.row.deviceCode)">编辑</el-button>
            <el-button type="danger" size="mini" icon="el-icon-delete" @click="handleDelete(scope.row.deviceCode)" v-show="!scope.row.root">删除</el-button>
          </template>
        </el-table-column>

    </el-table>
    <div id="title">
      <!--<h1>性能参数</h1>-->
    </div>

  </div>
</template>

<script>
  import { req } from '@/api/base/BaseApi'
  export default {
    name: 'index',
    data() {
      return {
        deviceCode: [],
        module: 'productBaseInfo',
        testTable: [],
        input1: '',
        productTable: [],
        listLoading: true,
        listQuery: {
          page: 1,
          size: 10,
          keyword: undefined
        },
        total: 0,
        list: null
      }
    },
    mounted: function() {
      this.show()
    },
    methods: {
      get: function() {
      },
      show() {
        req('/api/sys/auth/productBaseInfo/allList', 'POST', '').then(response => {
          this.productTable = response.data
          console.log(this.productTable)
        }).catch(() => console.log('page request error'))
      },
      searchDevice() {
        req('/api/sys/auth/productBaseInfo/deviceCode/' + this.input1, 'GET').then(response => {
          this.productTable = response.data
          console.log(this.productTable)
        }).catch(() => console.log('page request error'))
      },
      handleDelete(deviceCode) {
        console.log(deviceCode)
        this.listLoading = true
        const st = {
          deviceCode: deviceCode
        }
        req('/api/sys/auth/productBaseInfo/delete', 'GET', st).then(res => {
          this.show()
        }).catch(e => {
          this.listLoading = false
        })
        // del(this.module, name).then(res => {
        //   this.page()
        // }).catch(e => {
        //   this.listLoading = false
        // })
      },
      editPeople(deviceCode) {
        this.$router.push({ path: '/otherdata/productdesign/edit', query: { deviceCode: deviceCode }})
      }
    }
  }
</script>

<style scoped>
  h1{
    font-weight: normal;
    text-align: center;
    color: #808080;
    font-size: 25px;
  }
</style>
